package com.four.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public static JsonResult ok(){
        JsonResult jsonResult = new JsonResult();
        //根据不同情况返回指定Code值
        jsonResult.setCode(200);
        jsonResult.setMsg("success");

        return jsonResult;
    }

    public static JsonResult error(){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(-1);
        jsonResult.setMsg("fail");

        return jsonResult;
    }
}